from itsdangerous import URLSafeTimedSerializer as Serializer
from meiduo_mall import settings

def generic_email_verify_token(user_id):
    s=Serializer(settings.SECRET_KEY)
    token = s.dumps({'user_id':user_id})
    return token

def check_verify_token(token):
    s = Serializer(settings.SECRET_KEY)
    try:
        result = s.loads(token)
    except Exception as e:
        return None
    return result.get('user_id')
